#include "Tile.hpp"

Tile::Tile():
    Object2D("", "", 0, 0, 0, 0),
    _pixmap(NULL)
{
}

Tile::Tile(QString const& name, QPixmap *pixmap, const int positionX, const int positionY):
    Object2D(name, "", pixmap->width(), pixmap->height(), positionX, positionY),
    _pixmap(pixmap)
{
}

void    Tile::draw(QPainter& painter, const int mapPositionX, const int mapPositionY)
{
    int     realXPosition = _positionX - mapPositionX;
    int     realYPosition = _positionY - mapPositionY;

    if (_pixmap != NULL)
    {
        painter.drawPixmap(realXPosition * TILE_SIZE, realYPosition * TILE_SIZE, _width, _height, *_pixmap);
    }

}

void            Tile::setPixmap(QPixmap* pixmap)
{
    _pixmap = pixmap;
    _width = pixmap->width();
    _height = pixmap->height();
}


